<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增项目')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-user-add" class="form-horizontal">
        <input name="deptId" type="hidden" id="treeId"/>
<!--        <h4 class="form-header h4">基本信息</h4>-->
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">客户编号：</label>
                    <div class="col-sm-8">
                        <input name="customerNo" placeholder="请输入客户编号" autocomplete="off" class="form-control" type="text" maxlength="30"
                               required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">客户组编号：</label>
                    <div class="col-sm-8">
                        <input name="customerGroupNo" placeholder="请输入客户组编号" class="form-control"autocomplete="off" type="text" maxlength="30"
                               >
                    </div>
                </div>
            </div>

        </div>
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">客户名称：</label>
                    <div class="col-sm-8">
                        <input id="customerName" name="customerName" placeholder="请输入客户名称" class="form-control" autocomplete="off"
                               type="text" maxlength="30" >

                        <!--<span class="input-group-addon"><i class="fa fa-taxi"></i></span>-->
                        <!--<input class="form-control" type="text" name="deptName" onclick="selectDeptTree()"
                               placeholder="请选择部门"
                               id="treeName">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>-->
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">客户简称：</label>
                    <div class="col-sm-8">
                        <input id="simpleName" name="simpleName"class="form-control" placeholder="请输入客户简称"autocomplete="off"  type="text"
                               maxlength="30" >
                    </div>
                </div>
            </div>

        </div>


        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">是否可用：</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <select id="useable" name="useable" class="form-control" type="text" required>
                                <option value="Y">允许</option>
                                <option value="N">不允许</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <!--<h4 class="form-header h4">其他信息</h4>-->
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">备注：</label>
                    <div class="col-xs-10">
                        <textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
                    </div>
                </div>
            </div>
        </div>


    </form>
</div>

<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script>
    var prefix = ctx + "bas/customer";
    var ItemCodeInfoDlg = {
        data: {
            deptId: ""
        }
    };

    //项目保存
    function submitHandler() {
        var password = $("#password").val();
        if (true) {
            var data = $("#form-user-add").serializeArray();
            $.operate.saveTab(prefix + "/add", data);
        }
    }


    /* 选择部门树 */
    function selectDeptTree() {
        var deptId = $.common.isEmpty($("#treeId").val()) ? "1" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        selectgroup();
        layer.close(index);
    }

    //分配项目组
    function selectgroup() {
        var deptId = $("#treeId").val();
        var url = ctx + "system/item/selectPrjgroupByDeptId/" + deptId;
        $.get(url, function (result) {
            var html = ""
            for (var i = 0; i < result.length; i++) {
                html += "<option  value=" + result[i].prjgroupId + ">" + result[i].prjgroupName + "</option>"
            }
            $("#prjGroup").html(html)
            console.log(result)
        })

    }
    //分配项目参与人员
    /*function selectelopy() {
        var deptId = $("#treeId").val();
        var url = ctx + "system/item/selectEmployeeByDeptId/" + deptId;
        $.get(url, function (result) {
            console.log(result)
            var html = ""
            for (var i = 0; i < result.length; i++) {
                html += "<option  value=" + result[i].employeeId + ">" + result[i].name + "</option>"
            }
            $("#emplyIds").html(html)
            console.log(result)
        })

    }*/
</script>
</body>
</html>